package com.baomidou.springboot.db;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {

    @Bean(name = "db1")
    @ConfigurationProperties(prefix = "spring.datasource.mysql-db1")
    public DataSource dataSource1(){
        DruidDataSource build = DruidDataSourceBuilder.create().build();
        return build;
    }

    @Bean(name = "db2")
    @ConfigurationProperties(prefix = "spring.datasource.mysql-db2")
    public DataSource dataSource2(){
        DruidDataSource build = DruidDataSourceBuilder.create().build();
        return build;
    }
}

